﻿using PoemGame.Domain.PlayerAggregate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PoemGame.Domain.GameAggregate;

namespace PoemGame.Repository.MongoDb.Test
{
    public class TestGameRepository
    {
        [Fact]
        public async void TestAddGame()
        {
            var conf = Utility.GetConfiguration();

            var repository = new GameRepository(Utility.GetDb((conf)));
            var game = new Game(Guid.Empty, new GameType("Feihualing", ""), PlayType.Inturn, "测试", "花");

            await repository.AddAsync(game);

            Assert.NotEqual(Guid.Empty, game.Id);

            var playerRepository = new PlayerRepository(Utility.GetDb((conf)));

            var player = await playerRepository.GetPlayerByUserNameAsync("zhangsan");

            game.CreatorJoinGame(player);

            await repository.UpdateAsync(game);

            Assert.NotEmpty(game.PlayersInGame);
        }

    }
}
